﻿using System.Collections.Generic;
using System;
using System.Security.Cryptography;

namespace caufingHealth
{
    /// <summary>
    /// Interface class creating a contract for accessing and modifying
    /// data from a datasource.  
    /// 
    /// ***This is an non-final interface so there may
    /// be additional changes, such as if we go with a secondary class
    /// that handles data retention instead of my current solution***
    /// 
    /// <author>Aaron C. Schwan</author>
    /// <version>2011/09/28</version>
    /// </summary>
    public interface IData
    {
        /**
         * Methods that are required to perform the search function.
         * The return values on these methods is an array of lists
         * which have  key value pairs such that name is the attribute name
         * and the value is the value of the attribute for that tuple.
         * 
         * The methods available allow for searching by date of birth, name
         * or combination of the two.
         **/
        ///
        /// <summary>
        /// Searches a DataSource for records using the name of the patient.
        /// </summary>
        /// <param name="name">the name of the patient</param>
        /// <returns>a collection of tuples that match the search parameters</returns>
         List<KeyValuePair<string, object>>[] Search(string firstName, string lastName);

        /// <summary>
        /// Searches a DataSource for records using the patients date of birth.
        /// </summary>
        /// <param name="dateOfBirth">the date of birth of the patient</param>
        /// <returns>a collection of tuples that match the search parameters</returns>
         List<KeyValuePair<string, object>>[] Search(DateTime dateOfBirth);

        /// <summary>
        /// Searches a DataSource using a combination of the patients DOB and
        /// their name.
        /// </summary>
        /// <param name="name">the patients name</param>
        /// <param name="dateOfBirth">the patients date of birth</param>
        /// <returns>a collection of tuples that match the search parameters</returns>
         List<KeyValuePair<string, object>>[] Search(string firstName, string lastName, DateTime dateOfBirth);

        /**
         * Methods for adding, modifying, retrieving, and deleting patient data.
         **/

        /// <summary>
        /// Method for adding a new patient record to the store.
        /// </summary>
        /// <param name="firstName">First name of the patient</param>
        /// <param name="lastName">Last name of the patient</param>
        /// <returns>the patient ID number for the newly added patient</returns>
        /// <exception cref="System.ArguementNullException">a required parameter is null</exception>
     //    int AddPatientRecord(string firstName, string lastName, DateTime dateOfBirth);
         bool AddPatientRecord(PatientInformation.PatientRecord pRecord);
        
        /// <summary>
        /// Method for updating a patients record in the datastore.
        /// </summary>
        /// <param name="PatientID">the patients record number being updated</param>
        /// <param name="updateData">the data to be updated with Key pairing of
        ///             attribute name and value</param>
        /// <returns>the number of records updated</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int UpdatePatientRecord(int PatientID, List<KeyValuePair<string,string>> updatedPatientData);

        /// <summary>
        /// Retrieves the tuple record for patient ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient</param>
        /// <returns>List of key value pairings contianing patient data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
         List<KeyValuePair<string, object>>[] GetPatientRecord(int patientID);

        /// <summary>
        /// Deletes a patients records from the database.
        /// </summary>
        /// <param name="patientID">Patient ID of the patient</param>
        /// <returns>the number of records deleted</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int DeletePatientRecord(int patientID);
       
        /**
         * Methods for manipulating and retrieving data for labs
         **/
        /// <summary>
        /// Adds a lab record.
        /// </summary>
        /// <param name="patientID">patient ID of the patient the lab was ordered for</param>
        /// <param name="labData">Information on the lab type (To be determined)</param>
        /// <returns>the id of the lab record created </returns>
        /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int AddLabRecord(int patientID, List<KeyValuePair<string, string>> labData);
        
        /// <summary>
        /// Updates the pre-existing lab record.
        /// </summary>
        /// <param name="labID">the id number for the lab record being updated</param>
        /// <param name="labData">Information on the lab type (To be determined)</param>
        /// <returns>number of records updated</returns>
        /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int UpdateLabRecord(int labID, List<KeyValuePair<string, string>> labData);

        /// <summary>
        /// Retrieves information on a specified lab.
        /// </summary>
        /// <param name="labID">the id number for the lab record being retrieved</param>
        /// <returns>the lab data</returns>
        /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
         List<KeyValuePair<string, string>> GetLabRecord(int labID);

        /**
         * Methods for authenticating employees
         **/
        /// <summary>
        /// Retrieves the employee id of an employee.  This method
        /// is used for getting data required for calling the
        /// Authenticate method.
        /// </summary>
        /// <param name="firstName">the first name of the employee</param>
        /// <param name="lastName">the last name of the employee</param>
        /// <returns>employee id number</returns>
        /// <exception cref="System.ArgumentException">if the specified employee does not exist</exception>
         int GetEmployeeID(string firstName, string lastName);

        /// <summary>
        /// Authenticates whether an employee has provided to correct password.
        /// </summary>
        /// <param name="employeeID">the employee ID of the employee being authenticated</param>
        /// <param name="securePassword">a SHA-1 encrypted password</param>
        /// <returns>true if passwords matched, false if they don't</returns>
        /// <exception cref="System.ArgumentNullException">if password is null</exception>
        /// <exception cref="System.ArgumentException">if there is no record associated with employeeID</exception>
         bool Authenticate(int employeeID, string securePassword);

         /// <summary>
         /// Searches a DataSource using a combination of the patients DOB and
         /// their last name.
         /// </summary>
         /// <param name="name">the patients last name</param>
         /// <param name="dateOfBirth">the patients date of birth</param>
         /// <returns>a collection of tuples that match the search parameters</returns>
         List<KeyValuePair<string, object>>[] Search(string lastname, DateTime dateOfBirth);

        /////////////////////////////////////////////////////////////////////////////////////
        ///// Experimental Methods
        /////////////////////////////////////////////////////////////////////////////////////

         /// <summary>
         /// Searches a DataSource for records using the name of the patient.
         /// </summary>
         /// <param name="firstName">first name of patient</param>
         /// <param name="lastName"> last name of patient</param>
         /// <returns>a collection of tuples that math the search parameters</returns>
         PatientInformation.PatientRecord[] suchen(string firstName, string lastName);

         /// <summary>
         /// Searches a DataSource for records using the patients date of birth.
         /// </summary>
         /// <param name="dateOfBirth">the date of birth of the patient</param>
         /// <returns>a collection of tuples that match the search parameters</returns>
         PatientInformation.PatientRecord[] suchen(DateTime dateOfBirth);

         /// <summary>
         /// Searches a DataSource using a combination of the patients DOB and
         /// their name.
         /// </summary>
         /// <param name="name">the patients name</param>
         /// <param name="dateOfBirth">the patients date of birth</param>
         /// <returns>a collection of tuples that match the search parameters</returns>
         PatientInformation.PatientRecord[] suchen(string firstName, string lastName, DateTime dateOfBirth);

         /// <summary>
         /// Searches a DataSource using a combination of the patients DOB and
         /// their last name.
         /// </summary>
         /// <param name="name">the patients last name</param>
         /// <param name="dateOfBirth">the patients date of birth</param>
         /// <returns>a collection of tuples that match the search parameters</returns>
         PatientInformation.PatientRecord[] suchen(string lastname, DateTime dateOfBirth);

        /// <summary>
        /// Method for updating a patients record in the datastore.
        /// </summary>
        /// <param name="PatientID">the patients record number being updated</param>
        /// <param name="updateData">the data to be updated with Key pairing of
        ///             attribute name and value</param>
        /// <returns>the number of records updated</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int updatePatientRecord(int PatientID, PatientInformation.PatientRecord updatedPatientData);


         /// <summary>
         /// Retrieves the tuple record for patient ID.
         /// </summary>
         /// <param name="patientID">Patient ID for the patient</param>
         /// <returns>List of key value pairings contianing patient data</returns>
         /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
         PatientInformation.PatientRecord[] getPatientRecord(int patientID);

         /// <summary>
         /// Deletes a patients records from the database.
         /// </summary>
         /// <param name="patientID">Patient ID of the patient</param>
         /// <returns>the number of records deleted</returns>
         /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
         /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int deletePatientRecord(int patientID);

        /// <summary>
        /// Adds a patients visit records from the database.
        /// </summary>
        /// <param name="patientID">Patient ID of the patient</param>
        /// <param name="date">date of the visit</param>
        /// <param name="nurseID">id of the nurse</param>
        /// <param name="visit">visit information</param>
        /// <returns>the number of records deleted</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int addPatientVisitRecord(int nurseID, DateTime date, int patientID, PatientInformation.PatientRecord.PatientVisitRecord visit);

        /// <summary>
        /// Retrieves the tuple record for patient visit ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient visit</param>
        /// <returns>the number of records updated visit data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        PatientInformation.PatientRecord.PatientVisitRecord[] getPatientVisitRecord(int patientID);

        /// <summary>
        /// Retrieves the tuple record for patient visit ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient visit</param>
        /// <param name="nurseID">Nurse ID for the patient visit</param>
        /// <returns>the number of records updated visit data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        PatientInformation.PatientRecord.PatientVisitRecord[] getPatientVisitRecord(int nurseID, int patientID);

        /// <summary>
        /// Method for updating a patients record in the datastore.
        /// </summary>
        /// <param name="PatientID">the patients record number being updated</param>
        /// <param name="updateData">the data to be updated with Key pairing of
        ///             attribute name and value</param>
        /// <returns>the number of records updated</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int updatePatientVisitRecord(int PatientID, DateTime date, PatientInformation.PatientRecord.PatientVisitRecord updatedPatientData);

        /// <summary>
        /// Deletes a patients records from the database.
        /// </summary>
        /// <param name="patientID">Patient ID of the patient</param>
        /// <returns>the number of records deleted</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int deletePatientVisitRecord(int patientID, long date);
        
        /// <summary>
        /// Adds a patients lab records from the database.
        /// </summary>
        /// <param name="patientID">Patient ID of the patient</param>
        /// <param name="date">date of the visit</param>
        /// <param name="nurseID">id of the nurse</param>
        /// <param name="doctorID"> id of the doctor</param>
        /// <param name="lab">lab information</param>
        /// <returns>the number of records deleted</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int addPatientLabRecord(int nurseID, int patientID, int doctorID, long date, int type, int result);


        /// <summary>
        /// Retrieves the tuple record for patient lab ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient lab</param>
        /// <param name="nurseID">Nurse ID for the patient lab</param>
        /// <returns>the number of records updated patient lab data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        PatientInformation.PatientRecord.PatientLabRecord[] getPatientLabRecord(int nurseID, int patientID);

        /// <summary>
        /// Retrieves the tuple record for patient lab ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient lab</param>
        /// <param name="date"> date of the lab test</param>
        /// <returns>the number of records updated patient lab data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        PatientInformation.PatientRecord.PatientLabRecord[] getPatientLabRecord(long date, int patientID);

        /// <summary>
        /// Retrieves the tuple record for patient's lab ID.
        /// </summary>
        /// <param name="patientID">Patient ID for the patient lab</param>
        /// <param name="date"> date of the lab test</param>
        /// <param name="doctorID">doctor who ordered the test</param>
        /// <returns>the number of records updated patient lab data</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        PatientInformation.PatientRecord.PatientLabRecord[] getPatientLabRecord(DateTime date, int patientID, int doctorID);


        /// <summary>
        /// Method for updating a patient's lab record in the datastore.
        /// </summary>
        /// <param name="PatientID">the patients record number being updated</param>
        /// <param name="date"> date of lab test</param>
        /// <param name="updateData">the data to be updated with Key pairing of
        ///             attribute name and value</param>
        /// <returns>the number of records updated</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int updatePatientLabRecord(int nurseID, int patientID, int doctorID, long date, int type, int result);

        /// <summary>
        /// Deletes a patient's lab records from the database.
        /// </summary>
        /// <param name="patientID">Patient ID of the patient</param>
        /// <param name="date"> date of lab test</param>
        /// <returns>the number of records deleted</returns>
        /// <exception cref="System.ArgumentException">if there is no record associated with the id</exception>
        /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
        int deletePatientLabRecord(int patientID, DateTime date);

        LabTestInformation[] GetAvailableTests();
        DoctorInformation[] GetDoctorInformation();
        System.Data.DataTable AdminQuery(string query);
        bool isAdmin(int loginID);
   //     PatientInformation.PatientRecord.PatientLabRecord[] getPatientLabRecord(DateTime visitDate, int patientID);
         /**
          * Methods for manipulating and retrieving data for labs
          **/
        /*
         /// <summary>
         /// Adds a lab record.
         /// </summary>
         /// <param name="patientID">patient ID of the patient the lab was ordered for</param>
         /// <param name="labData">Information on the lab type (To be determined)</param>
         /// <returns>the id of the lab record created </returns>
         /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
         /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int addLabRecord(int patientID, List<KeyValuePair<string, string>> labData);

         /// <summary>
         /// Updates the pre-existing lab record.
         /// </summary>
         /// <param name="labID">the id number for the lab record being updated</param>
         /// <param name="labData">Information on the lab type (To be determined)</param>
         /// <returns>number of records updated</returns>
         /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
         /// <exception cref="System.FormatException">if there is an invalid key/value pair</exception>
         int updateLabRecord(int labID, List<KeyValuePair<string, string>> labData);

         /// <summary>
         /// Retrieves information on a specified lab.
         /// </summary>
         /// <param name="labID">the id number for the lab record being retrieved</param>
         /// <returns>the lab data</returns>
         /// <exception cref="System.ArgumentException">if there is no lab record associated with the id</exception>
         List<KeyValuePair<string, string>> getLabRecord(int labID);
         */
    }
}
